package com.liuzhilong.infrastructure.demo.state.machine.spring.simpleleave;

import com.liuzhilong.infrastructure.demo.state.machine.spring.simpleleave.definiton.LeaveApplyEvent;
import com.liuzhilong.infrastructure.demo.state.machine.spring.simpleleave.definiton.LeaveApplyState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.statemachine.StateMachine;
import org.springframework.stereotype.Component;

public class SimpleLeaveTest {
    @Autowired
    private StateMachine<LeaveApplyState, LeaveApplyEvent> stateMachine;
    @EventListener()
    public void initTests(ContextRefreshedEvent contextRefreshedEvent) {
        stateMachine.sendEvent(LeaveApplyEvent.SUBMIT);
        stateMachine.sendEvent(LeaveApplyEvent.REJECT);
        stateMachine.sendEvent(LeaveApplyEvent.SUBMIT);
        stateMachine.sendEvent(LeaveApplyEvent.PASS);
        stateMachine.sendEvent(LeaveApplyEvent.PASS);
        stateMachine.sendEvent(LeaveApplyEvent.CLOSE);

    }


}
